home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 4
/
Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso
/
Development
/
Source
/
DBL Pascal Library
/
DefProcs
/
SICN Cntl
/
SICN Test.p
< prev
next >
Wrap
Text File
|
1992-03-02
|
2KB
|
96 lines
program IconTest;
const
dialogID = 128;
firstIconButton = 2;
upDnIconButton = 3;
lastIconButton = 4;
disableCheckbox = 5;
hideCheckbox = 6;
reportText = 7;
var
theDialog: DialogPtr;
itemHit: Integer;
i: Integer;
evt: EventRecord;
function GetControlHandle (item: Integer): ControlHandle;
var
kind: Integer;
h: Handle;
r: Rect;
begin
GetDItem(theDialog, item, kind, h, r);
if BAND(kind, $FC) = ctrlItem then
GetControlHandle := ControlHandle(h)
else
GetControlHandle := nil;
end;
procedure ReportValue (item: Integer);
var
value: Integer;
theString: Str255;
kind: Integer;
h: Handle;
r: Rect;
begin
value := GetCtlValue(GetControlHandle(item));
NumToString(value, theString);
GetDItem(theDialog, reportText, kind, h, r);
SetIText(h, theString);
end;
begin
theDialog := GetNewDialog(dialogID, nil, POINTER(-1));
SetPort(theDialog);
TextFont(geneva); {Try different fonts and sizes to see how useWFont variant works…}
TextSize(9);
ShowWindow(theDialog);
for i := 1 to 3 do {Have to do this to synchronize TE items to the window font!}
if EventAvail(everyEvent, evt) then
;
with DialogPeek(theDialog)^.textH^^ do
begin
txFont := theDialog^.txFont;
txSize := theDialog^.txSize;
end;
InitCursor;
repeat
ModalDialog(nil, itemHit);
if itemHit = firstIconButton then
case GetCtlValue(GetControlHandle(firstIconButton)) of
0, 1:
;
otherwise
SysBeep(5);
end;
if itemHit = upDnIconButton then
SysBeep(1);
if itemHit = disableCheckbox then
begin
SetCtlValue(GetControlHandle(disableCheckbox), 1 - GetCtlValue(GetControlHandle(disableCheckbox)));
if GetCtlValue(GetControlHandle(disableCheckbox)) = 0 then
HiliteControl(GetControlHandle(lastIconButton), 0)
else
HiliteControl(GetControlHandle(lastIconButton), 255);
end;
if itemHit = hideCheckbox then
begin
SetCtlValue(GetControlHandle(hideCheckbox), 1 - GetCtlValue(GetControlHandle(hideCheckbox)));
if GetCtlValue(GetControlHandle(hideCheckbox)) = 0 then
ShowControl(GetControlHandle(lastIconButton))
else
HideControl(GetControlHandle(lastIconButton));
end;
ReportValue(itemHit);
until itemHit = OK;
DisposDialog(theDialog);
end.